package principal;

import java.io.*;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

import redesN.redeMLP;


public class Principal
{

	/**
	 * @param args
	 */
	//oi
	public static void myExcel()
	{
		String filename = "teste.xls";
		
		File excelFile = new File(filename);
		
		try
		{
			FileInputStream fis = new FileInputStream(excelFile);
			Workbook workbook = WorkbookFactory.create(fis);
			fis.close();
			
			String sheetName = "first sheet";

			Sheet S1 = workbook.getSheet(sheetName);
			if (S1 == null)
			{
				S1 = workbook.createSheet(sheetName);
			}
			Row R1 = S1.createRow(0);
			Cell C1 = R1.createCell(0);
			C1.setCellValue(200);
			
			FileOutputStream fos = new FileOutputStream(excelFile);
			workbook.write(fos);
			fos.close();
			
		} catch( FileNotFoundException e ) {
			e.printStackTrace();
		} catch( InvalidFormatException e ) {
			e.printStackTrace();
		} catch( IOException e ) {
			e.printStackTrace();
		}
		
	}
	
	public static void main(String[] args)
	{
		// TODO tirar as coisas do main (farei assim que estiver escrevendo o programa mesmo)
		
		redeMLP.criarede();
		
		
		
		//Principal.myExcel();
		
		//NÃO APAGAR COISAS "INUTEIS" COMENTADAS: elas são de utilidade didática
		
		/*String filename = "Afl.xlsm";
		
		System.out.println( "fileName: " + args[0] ) ;
		System.out.println( "cell: " + args[1] ) ;

		File excelFile = new File( filename ) ;

		try {
			//dá catch "file not found", "ioexception", "invalid format"
			
			//capta o stream
			FileInputStream fis = new FileInputStream(excelFile);
			Workbook workbook = WorkbookFactory.create(fis);
			fis.close();
			
			//pega sheet
			Sheet mysheet = workbook.getSheet("IMPRESSÃO PRG_nova");
			//pega linha
			Row row1 = mysheet.getRow(5);
			//pega celula da linha (coluna)
			Cell cellA1 = row1.getCell((short) 4);
			double a1Val = cellA1.getNumericCellValue();
			System.out.println(a1Val);
					
			

		} catch( FileNotFoundException e ) {
			e.printStackTrace();
		} catch( InvalidFormatException e ) {
			e.printStackTrace();
		} catch( IOException e ) {
			e.printStackTrace();
		}*/
	}

}
